package com.woniu.dating.service.impl;

import com.woniu.dating.dto.DynamicDTO;
import com.woniu.dating.mapper.DatingConcernMapper;
import com.woniu.dating.pojo.DatingConcern;
import com.woniu.dating.pojo.DatingDynamic;
import com.woniu.dating.mapper.DatingDynamicMapper;
import com.woniu.dating.service.IDatingDynamicService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.dating.vo.DatingLoginVO;
import com.woniu.dating.vo.DynamicVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 玖柒
 * @since 2023-05-20
 */
@Service
public class DatingDynamicServiceImpl extends ServiceImpl<DatingDynamicMapper, DatingDynamic> implements IDatingDynamicService {


    @Resource
    private DatingDynamicMapper datingDynamicMapper;

    @Resource
    private DatingConcernMapper datingConcernMapper;


    /**
     * 个人动态
     */
    @Override
    public List<DynamicVO> getDatingDynamic(DatingLoginVO datingLoginVO) {
        List<DynamicVO> listDynamicVO = datingDynamicMapper.getgetDatingDynamic(datingLoginVO.getUserId());
        return listDynamicVO;
    }

    /**
     * 根据userId
     */
    @Override
    public List<DynamicVO> getDatingDynamicPerson(Integer userId) {
        List<DynamicVO> listDynamicVO = datingDynamicMapper.getgetDatingDynamic(userId);
        return listDynamicVO;
    }

    /**
     * 删除动态
     */
    @Override
    public void deleteDynamic(DatingLoginVO datingLoginVO,Integer dynamicId) {
        datingDynamicMapper.deleteDynamic(datingLoginVO.getUserId(),dynamicId);
    }

    /**
     * 发布动态
     */
    @Override
    public void addDynamic(DatingLoginVO datingLoginVO, DynamicDTO dynamicDTO) {
        DatingDynamic datingDynamic = new DatingDynamic();
        BeanUtils.copyProperties(dynamicDTO,datingDynamic);
        datingDynamicMapper.insert(datingDynamic);
    }

    /**
     * 动态圈
     */
    @Override
    public List<DynamicVO> dynamicCircle(DatingLoginVO datingLoginVO) {
        //1.查询出当前用户关注的所有用户的动态
        List<DynamicVO> listDynamicCircle = datingDynamicMapper.dynamicCircle(datingLoginVO.getUserId());
        return listDynamicCircle;
    }
}
